<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue组件插槽</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="Application">
        <my-container>
            <button>自定义按钮</button>
        </my-container>
        <my-container2>
            <template #header>
                <h1>这里是头部元素</h1>
            </template>
        
            <template #main>
                <p>内容部分</p>
                <p>内容部分</p>
            </template>
        
            <template #footer>
                <p>这里是尾部元素</p>
            </template>
        </my-container2>
    </div>
    <script>
        const {createApp} = Vue
        const App = createApp({
        })
        const container2Component = {
            template:`<div>
                    <slot name="header"></slot>
                    <hr/>
                    <slot name="main"></slot>
                    <hr/>
                    <slot name="footer"></slot>
                </div>`
        }
        App.component("my-container2", container2Component)
        const containerComponent = {
            template:`<div style="border-style:solid;border-color:red; border-width:10px">
                    <slot>插槽的默认内容</slot>
                </div>`
        }
        App.component("my-container", containerComponent)
        App.mount("#Application") 
    </script>
</body>
</html>